public class Obj_polymorphism {
    public static void main(String[] args) {
        //对象多态
        People p = new Teacher();
        p.say(); //识别技巧：编译看左边，运行看右边
        System.out.println(p.name); //注意：对于变量，编译看左，运行看左
        People p2 = new Student();
        p2.say();
        System.out.println(p2.name);
    }
}
class Student extends People{
    public String name = "s变量";

    @Override
    public void say(){
        System.out.println("I am student");
    }

}
class Teacher extends  People {
    public String name = "t变量";

    @Override
    public void say(){
        System.out.println("老师跑步");
    }

    public void teach(){
        System.out.println("tset");
    }
}
class People{
    public String name = "people变量";
   public void say(){
       System.out.println("跑步");
   }
}
